home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / rexx / lhadir.dopus
Text File  |  1995-02-13  |  21KB  |  857 lines

  1. /*
  2.   $VER: LhADir.dopus 1.9 (2.9.94)
  3.   Copyright © 1993-1994 by EAV Productions International
  4.   Placed in the public domain. No restrictions on distribution or usage.
  5.  
  6.   LhADir.dopus is an ARexx script for Directory Opus that allows you to show
  7.   the contents of LhA archives in a DOpus window and operate on the files and
  8.   directories inside an archive as if it is a normal directory.
  9.  
  10.   Possible arguments (not case sensitive) for LhADir.dopus:
  11.  
  12.    GETDIR, BROWSE, PARENT, ROOT, DELETE, COPY, MOVE, MAKEDIR, GETSIZES,
  13.    READ, ANSIREAD, HEXREAD, SHOW, PLAY, LOOPPLAY, PRINT, ICONINFO, RUN,
  14.    VERSION, UNDMS, MULTIVIEW, AMIGAGUIDE, VIEWTEK, RETINADISPLAY.
  15. */
  16.  
  17.  
  18. signal on syntax    /* intercept syntax errors */
  19. options results        /* need results */
  20. options failat 21    /* external commands are allowed return code 20 */
  21. numeric digits 10    /* needed for convertdate routine */
  22. lf='a'x            /* ascii code for linefeed */
  23.  
  24. parse arg command portname . '"' selected '"'
  25. upper command
  26. if portname~=='' then
  27.    address(portname)
  28. else
  29.    portname=address()
  30. parse var portname '.' port  /* port number */
  31.  
  32. busy on            /* busy mouse pointer on */
  33. status 3        /* get active window */
  34. win=result
  35. status 9 win        /* get number of selected entries */
  36. entries=result
  37. checkabort        /* reset abort flag */
  38.  
  39. call checkconfig
  40. call checklhadir(win)
  41.  
  42. if selected~=='' then do
  43.    filetype=-1
  44.    entries=1
  45.    end
  46. else
  47.    if entries>0 then
  48.       call getnextone
  49.  
  50. topline=""
  51. listlha=0
  52. notmove=command~='MOVE'
  53. if pos('|'command'|','|GETDIR|BROWSE|PARENT|ROOT|DELETE|COPY|MOVE|MAKEDIR|GETSIZES|')>0 then
  54.    interpret 'call do'command
  55. else do
  56.    n=entries
  57.    async=pos('|'command'|','|READ|ANSIREAD|HEXREAD|')>0
  58.    internal=async|pos('|'command'|','|SHOW|PLAY|LOOPPLAY|PRINT|ICONINFO|RUN|')>0
  59.    if entries=0|async|(internal&~(lhadir&entries>0))|command='VERSION' then
  60.       n=1
  61.    thisfile=''
  62.  
  63.    do i=1 to n
  64.       checkabort
  65.       if result then
  66.      call quitit "Aborted..."
  67.  
  68.       if entries>0 then
  69.      if lhadir then do
  70.         if filetype>0 then
  71.            call quitit "Error, cannot view directories."
  72.         address command 'LhA e -q -x2 -Qo "'patch2(lhafile)'" T: "'patch(lhasubdir||selected)'"'
  73.         if rc>0 then
  74.            call quitit "Error while extracting file."
  75.         thisfile='"T:'selected'"'
  76.         end
  77.      else
  78.         if ~internal then
  79.            thisfile='"'selected'"'
  80.  
  81.       if internal then do
  82.      interpret '"'command '"'thisfile'""'
  83.      abort=result~=0
  84.      end
  85.       else do
  86.      if ~lhadir&entries>0 then
  87.         thisfile='"'winpath||selected'"'
  88.      query screenname
  89.      if result=0 then
  90.         screenname=portname  /* for compatibility */
  91.      else
  92.         screenname=result
  93.  
  94.      select  /* external commands */
  95.         when command='VERSION' then
  96.            call version
  97.         when command='UNDMS' then
  98.            call undms
  99.         when command='MULTIVIEW' then
  100.            address command 'MultiView' thisfile 'PUBSCREEN' screenname 'FONTNAME' fontname 'FONTSIZE' fontsize
  101.         when command='AMIGAGUIDE' then
  102.            address command 'AmigaGuide' thisfile 'PUBSCREEN' screenname
  103.         when command='VIEWTEK' then
  104.            address command 'Work:OtherTools/VT >NIL:' thisfile
  105.         when command='RETINADISPLAY' then
  106.            address command 'Work:Retina/RetinaTools/RetinaDisplay' thisfile
  107.         otherwise
  108.            call quitit "Error, LhADir.dopus does not support the command '"command"'."
  109.         end
  110.      abort=0
  111.      end
  112.  
  113.       busy on
  114.       if lhadir&entries>0 then do
  115.      if async then do
  116.         if ~show('l','rexxsupport.library') then
  117.            call addlib('rexxsupport.library',0,-30)  /* needed for delay() */
  118.         call delay(75)  /* wait a bit before deleting */
  119.         end
  120.      delete '"T:'selected'"'
  121.      busy on
  122.      end
  123.       if thisfile~=='' then do
  124.      selectfile '"'selected'" 0 1'  /* deselect item */
  125.      if topline=="" then
  126.         topline="OK"
  127.      end
  128.       if abort then
  129.      call quitit
  130.       if i<n then
  131.      call getnextone
  132.       end
  133.    end
  134.  
  135. call quitit topline  /* finished */
  136.  
  137.  
  138. dobrowse:
  139. dogetdir:
  140.  
  141.    if entries>0 then
  142.       if filetype>0 then  /* list a new dir */
  143.      if lhadir then
  144.         lhasubdir=lhasubdir||selected'/'
  145.      else
  146.         winpath=winpath||selected'/'
  147.       else do  /* list an archive file */
  148.      if pos('|'upper(right(selected,4)'|'),'|.LHA|.LZH|.RUN|')=0 then
  149.         call quitit "Error, LhADir.dopus can only list LhA archives."
  150.      if lhadir then do
  151.         request "This is an archive in an archive."lf"Extract it to 'T:' and then list it?"
  152.         uset=result
  153.         if uset then
  154.            destpath='T:'
  155.         else do
  156.            busy on
  157.            status 13 1-win  /* get window path */
  158.            destpath=result
  159.            if result=='' then
  160.           call quitit "Aborted..."
  161.            request "Use the current destination window"lf"'"destpath"' instead?"
  162.            if ~result then
  163.           call quitit "Aborted..."
  164.            end
  165.         busy on
  166.         toptext "Extracting from archive..."
  167.         address command 'LhA e -q -x2 -a -C0 -Qo "'patch2(lhafile)'" "'destpath'" "'patch(lhasubdir||selected)'"'
  168.         if rc>0 then
  169.            call quitit "Error while extracting from archive."
  170.         if ~uset&command='GETDIR' then
  171.            rescan 1-win
  172.         lhafile=destpath||selected
  173.         end
  174.      else
  175.         lhafile=winpath||selected
  176.      lhadir=1
  177.      lhasubdir=''
  178.      listlha=1
  179.      end
  180.    else  /* rescan current dir */
  181.       if lhadir then do
  182.      status 6 win  /* get number of entries */
  183.      listlha=result>0
  184.      end
  185.  
  186.    if command='BROWSE' then do
  187.       selectfile '"'selected'" 0 1'
  188.       call swapactive
  189.       end
  190.    if lhadir then do
  191.       call showlhadir
  192.       topline="OK"
  193.       end
  194.    else
  195.       status 13 win set '"'winpath'"'
  196.    return
  197.  
  198.  
  199. doparent:
  200.  
  201.    if lhadir&lhasubdir~=='' then do
  202.       cuthere=lastpos('/',lhasubdir,length(lhasubdir)-1)
  203.       lhasubdir=left(lhasubdir,cuthere)
  204.       call showlhadir
  205.       topline="OK"
  206.       end
  207.    else
  208.       parent
  209.    return
  210.  
  211.  
  212. doroot:
  213.  
  214.    if lhadir then do
  215.       cuthere=lastpos('/',lhafile,length(lhafile)-1)
  216.       if cuthere=0 then
  217.      cuthere=lastpos(':',lhafile)
  218.       status 13 win set '"'left(lhafile,cuthere)'"'
  219.       end
  220.    else
  221.       root
  222.    return
  223.  
  224.  
  225. dodelete:
  226.  
  227.    if lhadir then do
  228.       if entries=0 then
  229.      call quitit
  230.       if notmove then do
  231.      if askdelete then do
  232.         status 26 set "Delete"
  233.         request "Do you really wish to delete selected entries"lf"from archive?"
  234.         if ~result then
  235.            call quitit "Aborted..."
  236.         busy on
  237.         end
  238.      call getall
  239.      end
  240.       call open('actionfile','T:actionfile'port,'w')
  241.       do i=1 to entries
  242.      if type.i>0 then
  243.         wild='/#?'
  244.      else
  245.         wild=''
  246.      call writeln('actionfile','"'patch(lhasubdir||name.i)||wild'"')
  247.      removefile '"'name.i'" 0'
  248.      end
  249.       call close('actionfile')
  250.       toptext "Deleting from archive..."
  251.       address command 'LhA d -q -Qp -Qo "'patch2(lhafile)'" @T:actionfile'port
  252.       if rc>0 then do
  253.      topline="Error while deleting from archive."
  254.      listlha=1
  255.      call showlhadir
  256.      end
  257.       else do
  258.      topline="OK"
  259.      displaydir
  260.      end
  261.       delete 'T:actionfile'port
  262.       delete 'T:LhADir.list'port  /* archive contents has changed */
  263.       busy on
  264.       end
  265.    else do
  266.       if notmove then
  267.      restore
  268.       delete
  269.       end
  270.    return
  271.  
  272.  
  273. domove:
  274. docopy:
  275.  
  276.    if entries=0 then
  277.       call quitit
  278.    problem=0
  279.    source=winpath
  280.    s_lhadir=lhadir
  281.    s_lhafile=lhafile
  282.    s_lhasubdir=lhasubdir
  283.    call checklhadir(1-win)
  284.  
  285.    if s_lhadir then do
  286.       if winpath=='' then do
  287.      errortext="No destination directory selected!"
  288.      toptext errortext
  289.      notify errortext
  290.      call quitit
  291.      end
  292.       if lhadir then
  293.      winpath='T:LhADir'port'/'lhasubdir
  294.       call getall
  295.       call lhaextract
  296.       if lhadir then do
  297.      source=winpath
  298.      call lhaadd
  299.      end
  300.       else
  301.      if problem then
  302.         rescan 1-win
  303.      else do
  304.         do i=1 to entries
  305.            fileinfo '"'name.i'" /'
  306.            info.i=result
  307.            end
  308.         call swapactive
  309.         do i=1 to entries
  310.            parse var info.i name '/' size '/' '/' type '/' '/' days '/' seconds '/' comment '/' atts '/'
  311.            if type>0 then
  312.           size=0
  313.            addfile '"'name'"' size type seconds+days*86400 '"'comment'"' atts '0 0'
  314.            end
  315.         displaydir
  316.         call swapactive
  317.         end
  318.       end
  319.    else
  320.       if lhadir then do
  321.      call getall
  322.      call lhaadd
  323.      end
  324.       else do  /* normal copy/move */
  325.      restore
  326.      if notmove then
  327.         copy
  328.      else
  329.         move
  330.      end
  331.  
  332.    if (s_lhadir|lhadir)&~notmove&~problem then do
  333.       lhadir=s_lhadir
  334.       lhafile=s_lhafile
  335.       lhasubdir=s_lhasubdir
  336.       checkabort
  337.       if result then
  338.      call quitit "Aborted..."
  339.       call dodelete
  340.       end
  341.    return
  342.  
  343.  
  344. domakedir:
  345.  
  346.    getstring '"Enter directory name or archive name.lha"'
  347.    dirtomake=result
  348.    if rc|dirtomake=='' then
  349.       call quitit
  350.    now=date('i')*86400+time('s')
  351.    if lhadir then do  /* create empty dir in archive */
  352.       call createdirs dirtomake'/'
  353.       address command 'LhA a -q -e -r -Qo "'patch2(lhafile)'" T:LhADir'port'/' '"'patch(lhasubdir||dirtomake)'"'
  354.       if rc>0 then
  355.      topline="Error while adding to archive."
  356.       else do
  357.      topline="Directory created."
  358.      addfile '"'dirtomake'" 0 1' now '"" ----RWED 0 1'
  359.      end
  360.       delete 'T:LhADir'port
  361.       delete 'T:LhADir.list'port
  362.       busy on
  363.       end
  364.    else do
  365.       if upper(right(dirtomake,4))=='.LHA' then  /* create new archive */
  366.      if open('emptyarchive',winpath||dirtomake,'w') then do
  367.         call writech('emptyarchive','0'x)
  368.         call close('emptyarchive')
  369.         topline="Empty archive created."
  370.         addfile '"'dirtomake'" 1 -1' now '"" ----RWED 0 1'
  371.         end
  372.      else
  373.         topline="Error creating archive."
  374.       else do  /* normal makedir */
  375.      restore
  376.      makedir '"'dirtomake'"'
  377.      end
  378.       end
  379.    return
  380.  
  381.  
  382. dogetsizes:
  383.  
  384.    if lhadir then do
  385.       status 6 win  /* get total number of entries */
  386.       all=result
  387.       status 8 win  /* get number of dirs selected */
  388.       seldirs=result
  389.       n=1
  390.       do i=1 to all
  391.      getentry i
  392.      dirname.n=result
  393.      fileinfo '"'result'" /'
  394.      parse var result '/' filesize '/' '/' type '/' select '/'
  395.      if type>0&select&filesize=0 then
  396.         n=n+1
  397.      end
  398.       dirsize.=0
  399.       dirsecs.=0
  400.       ndirs=n-1
  401.       call readlist(0)
  402.       end
  403.    getsizes
  404.    return
  405.  
  406.  
  407. version:
  408.  
  409.    if entries=0 then
  410.       thisfile='REXX:LhADir.dopus'
  411.    toptext "Searching for version string..."
  412.    address command 'Version >T:Version.temp' thisfile 'FILE FULL'
  413.    call open('tempfile','T:Version.temp','r')
  414.    topline=readln('tempfile')
  415.    call close ('tempfile')
  416.    delete 'T:Version.temp'
  417.    return
  418.  
  419.  
  420. undms:
  421.  
  422.    if entries=0|upper(right(selected,4))~=='.DMS' then
  423.       call quitit "No DMS file selected."
  424.    drive.1='DF0:'
  425.    drive.0='RAD:'
  426.    status 26 set drive.1
  427.    status 27 set drive.0
  428.    toptext thisfile
  429.    request "Please insert disk and select"lf"destination drive for DMS file"
  430.    dest=result
  431.    busy on
  432.    checkabort
  433.    if result then
  434.       call quitit "Aborted..."
  435.  
  436.    address command 'Run >NIL: <NIL: DMS <NIL: >PIPE:dmsout WRITE' thisfile 'TO' drive.dest 'NOTEXT'
  437.    address command 'Status >T:ProcessNo COMMAND=DMS'
  438.    call open('temp','T:ProcessNo','r')
  439.    process=readln('temp')
  440.    close('temp')
  441.    delete 'T:ProcessNo'
  442.    busy on
  443.  
  444.    nomess=1
  445.    errors=''
  446.    buffer=''
  447.    call open('dmsout','PIPE:dmsout','r')
  448.    do until eof('dmsout')
  449.       buffer=buffer||readch('dmsout',25)
  450.       here=verify(buffer,'a0d'x,'m')
  451.       if here>0 then do
  452.      line=left(buffer,here-1)
  453.      if nomess&left(line,7)=='No Disk' then do
  454.         toptext "Insert disk in" drive.dest
  455.         nomess=0
  456.         end
  457.      parse var line ' ' line
  458.      buffer=substr(buffer,here+1)
  459.      if pos('ERROR',upper(line))>0 then do
  460.         errors=errors||lf||line
  461.         beep
  462.         busy on
  463.         end
  464.      if left(line,9)=='unPacking' then do
  465.         toptext selected '-' line
  466.         checkabort
  467.         if result then do
  468.            address command 'Break' process 'C'
  469.            topline="Aborted..."
  470.            end
  471.         end
  472.      end
  473.       end
  474.    call close('dmsout')
  475.    if errors~=='' then do
  476.       toptext thisfile
  477.       notify "Error Report"||lf||errors
  478.       end
  479.    return
  480.  
  481.  
  482. checklhadir:
  483.  
  484.    arg checkwin
  485.    status 13 checkwin  /* get window path */
  486.    winpath=result
  487.    test=upper(winpath)
  488.    cuthere=pos('.LHA/',test)
  489.    if cuthere=0 then
  490.       cuthere=pos('.LZH/',test)
  491.    if cuthere=0 then
  492.       cuthere=pos('.RUN/',test)
  493.    lhadir=cuthere>0
  494.    if lhadir then do
  495.       lhafile=left(winpath,cuthere+3)
  496.       lhasubdir=substr(winpath,cuthere+5)
  497.       end
  498.    return
  499.  
  500.  
  501. lhaextract:
  502.  
  503.    status 8 win  /* get number of dirs selected */
  504.    anydirs=result>0
  505.    mustmove=anydirs&s_lhasubdir~==''
  506.    if mustmove then
  507.       destpath=winpath'LhADir'port'/'
  508.    else
  509.       destpath=winpath
  510.  
  511.    call open('actionfile','T:actionfile'port,'w')
  512.    do i=1 to entries
  513.       if type.i>0 then
  514.      wild='/#?'
  515.       else
  516.      wild=''
  517.       call writeln('actionfile','"'patch(s_lhasubdir||name.i)||wild'"')
  518.       end
  519.    call close('actionfile')
  520.  
  521.    if anydirs then
  522.       lhacmd='x'
  523.    else
  524.       lhacmd='e -x2'
  525.    toptext "Extracting from archive..."
  526.    address command 'LhA' lhacmd '-q -a -C0 -Qo "'patch2(s_lhafile)'" "'destpath'" @T:actionfile'port
  527.    problem=rc>0
  528.    if problem then
  529.       topline="Error while extracting from archive."
  530.    else do
  531.       topline="OK"
  532.       if notmove then
  533.      none
  534.       end
  535.  
  536.    if mustmove then do
  537.       do i=1 to entries
  538.      move '"'winpath'LhADir'port'/'s_lhasubdir||name.i'" "'winpath'"'
  539.      end
  540.       delete '"'winpath'LhADir'port'"'
  541.       end
  542.    delete 'T:actionfile'port
  543.    busy on
  544.    return
  545.  
  546.  
  547. lhaadd:
  548.  
  549.    mustcopy=upper(right(source,length(lhasubdir)))~==upper(lhasubdir)
  550.    if mustcopy then do  /* all files must be copied to T: before they can be added */
  551.       homedir='T:LhADir'port'/'
  552.       call createdirs
  553.       end
  554.    else
  555.       homedir=left(source,length(source)-length(lhasubdir))
  556.    call open('actionfile','T:actionfile'port,'w')
  557.    call writeln('actionfile','"'patch(homedir)'"')
  558.  
  559.    if s_lhadir then
  560.       call writeln('actionfile','#?')
  561.    else do
  562.       do i=1 to entries
  563.      call writeln('actionfile','"'patch(lhasubdir||name.i)'"')
  564.      if mustcopy then do
  565.         copy '"'source||name.i'" "T:LhADir'port'/'lhasubdir'"'
  566.         busy on
  567.         end
  568.      end
  569.       end
  570.    call close('actionfile')
  571.  
  572.    if pos('.LZH/',test)>0 then
  573.       method='-0'
  574.    else
  575.       method=''
  576.    toptext "Adding to archive..."
  577.    address command 'LhA r' method '-q -e -r -Qo "'patch2(lhafile)'" @T:actionfile'port
  578.    problem=rc>0
  579.    if problem then
  580.       topline="Error while adding to archive."
  581.    else do
  582.       topline="OK"
  583.       if notmove then
  584.      none
  585.       end
  586.    delete 'T:actionfile'port
  587.    if mustcopy|s_lhadir then
  588.       delete 'T:LhADir'port
  589.    busy on
  590.    call swapactive
  591.    listlha=1
  592.    call showlhadir
  593.    call swapactive
  594.    return
  595.  
  596.  
  597. lhalist:
  598.  
  599.    address command 'LhA >T:LhADir.list'port 'vv -N -Qw -Qo "'lhafile'"'
  600.    if rc>0 then do
  601.       setwintitle '"<Directory not available>"'
  602.       call quitit "Error while listing archive."
  603.       end
  604.    return
  605.  
  606.  
  607. getnextone:
  608.  
  609.    getnextselected
  610.    selected=result
  611.    if follow then
  612.       scrolltoshow '"'selected'"'
  613.    fileinfo '"'selected'" /'
  614.    parse var result '/' '/' '/' filetype '/'
  615.    return
  616.  
  617.  
  618. getall:
  619.  
  620.    status 6 win  /* get total number of entries */
  621.    all=result
  622.    n=1
  623.    do i=1 to all
  624.       getentry i
  625.       name.n=result
  626.       fileinfo '"'result'" /'
  627.       parse var result '/' '/' '/' type.n '/' select '/'
  628.       if select then
  629.      n=n+1
  630.       if n>entries then
  631.      leave
  632.       end
  633.    return
  634.  
  635.  
  636. createdirs:
  637.  
  638.    parse arg subdir
  639.    dirstocreate='T:LhADir'port'/'lhasubdir||subdir
  640.    here=0
  641.    do forever
  642.       here=pos('/',dirstocreate,here+1)
  643.       if here=0 then
  644.      leave
  645.       makedir '"'left(dirstocreate,here-1)'"'
  646.       end
  647.    busy on
  648.    return
  649.  
  650.  
  651. swapactive:
  652.  
  653.    otherwindow
  654.    win=1-win
  655.    return
  656.  
  657.  
  658. showlhadir:
  659.  
  660.    status 13 win set '"'lhafile'/'lhasubdir'"'
  661.    toptext "Listing archive..."  /* toptext obscures error message */
  662.    setwintitle '"LhADir listed archive"'
  663.    now=date('i')*86400+time('s')
  664.    ndirs=0
  665.    call readlist(1)
  666.    return
  667.  
  668.  
  669. readlist:
  670.  
  671.    arg show  /* showdir or getsizes? */
  672.    if listlha|~exists('T:LhADir.list'port) then
  673.       call lhalist
  674.    call open('tempfile','T:LhADir.list'port,'r')
  675.    nextline=readln('tempfile')
  676.    parse var nextline 21 whicharc "':"
  677.    if upper(whicharc)~==upper(lhafile) then do  /* it's another archive's list */
  678.       call close('tempfile')
  679.       call lhalist
  680.       call open('tempfile','T:LhADir.list'port,'r')
  681.       call readln('tempfile')
  682.       end
  683.    do 2
  684.       call readln('tempfile')  /* waste these 2 lines */
  685.       end
  686.  
  687.    compstr=upper(lhasubdir)
  688.    complen=length(compstr)
  689.    nextline=readln('tempfile')
  690.  
  691.    do forever
  692.  
  693.       name=nextline
  694.       infoline=readln('tempfile')
  695.       do while pos('% ',infoline)<22
  696.      name=infoline
  697.      infoline=readln('tempfile')
  698.      end
  699.       if name=='-------- ------- ----- --------- --------' then
  700.      leave
  701.       nextline=readln('tempfile')
  702.       if left(nextline,1)==':' then do
  703.      parse var nextline 3 comment
  704.      nextline=readln('tempfile')
  705.      end
  706.       else
  707.      comment=''
  708.  
  709.       if upper(left(name,complen))==compstr then do
  710.      name=substr(name,complen+1)
  711.      if name~==''&pos('"',name)=0 then do
  712.         if pos('/',name)>0 then do  /* it's a dir */
  713.            parse var name dirname '/'
  714.            olddir=0
  715.            do i=ndirs to 1 by -1
  716.           if upper(dirname)==upper(dirname.i) then do
  717.              olddir=1
  718.              if ~show then do
  719.             toptext winpath||name
  720.             parse var infoline size . '% ' datestamp +18
  721.             dirsize.i=dirsize.i+size
  722.             seconds=convertdate(datestamp)
  723.             if seconds>dirsecs.i then
  724.                dirsecs.i=seconds
  725.             end
  726.              leave
  727.              end
  728.           end
  729.            if show&~olddir then do  /* a new dir */
  730.           ndirs=ndirs+1
  731.           dirname.ndirs=dirname
  732.           addfile '"'dirname'" 0 1' now '"" ----RWED 0 0'
  733.           end
  734.            end
  735.         else  /* it's a file */
  736.            if show then do
  737.           parse var infoline size . '% ' datestamp +18 +1 atts .
  738.           seconds=convertdate(datestamp)
  739.           addfile '"'name'"' size '-1' seconds '"'comment'"' atts '0 0'
  740.           end
  741.         end
  742.      end
  743.       end
  744.    call close('tempfile')
  745.    if ~show then
  746.       do i=1 to ndirs
  747.      addfile '"'dirname.i'"' dirsize.i '1' dirsecs.i '"" ----RWED 0 0'
  748.      selectfile '"'dirname.i'"'
  749.      end
  750.    displaydir
  751.    return
  752.  
  753.  
  754. convertdate:  /* convert a file's date stamp to seconds past 01-Jan-78 */
  755.  
  756.    parse arg day '-' month '-' year ' ' hours ':' minutes ':' seconds
  757.    century=19+(year<78)
  758.    month=pos(month,'  JanFebMarAprMayJunJulAugSepOctNovDec')/3
  759.    month=right(month,2,'0')
  760.    return seconds+minutes*60+hours*3600+date('i',century||year||month||day,'s')*86400
  761.  
  762.  
  763. patch:  /* patch file names containing pattern matching tokens */
  764.  
  765.    parse arg patched
  766.    pos=1
  767.    do forever
  768.       here=verify(substr(patched,pos),"*#?|%()[]~'",'m')
  769.       if here=0 then
  770.      leave
  771.       pos=pos+here+1
  772.       patched=insert("'",patched,pos-3)
  773.       end
  774.    do forever
  775.       here=verify(substr(patched,pos),'@','m')
  776.       if here=0 then
  777.      leave
  778.       pos=pos+here+1
  779.       patched=insert("*",patched,pos-3)
  780.       end
  781.    return patched
  782.  
  783.  
  784. patch2:  /* for LhA file names */
  785.  
  786.    parse arg patched
  787.    pos=1
  788.    do forever
  789.       here=verify(substr(patched,pos),'*#?|%()[]~','m')
  790.       if here=0 then
  791.      leave
  792.       pos=pos+here+1
  793.       patched=insert("'",patched,pos-3)
  794.       end
  795.    do forever
  796.       here=verify(substr(patched,pos),"@'",'m')
  797.       if here=0 then
  798.      leave
  799.       pos=pos+here+1
  800.       patched=insert("*",patched,pos-3)
  801.       end
  802.    return patched
  803.  
  804.  
  805. syntax:
  806.  
  807.    call quitit "Syntax Error" rc"," errortext(rc) "in line" sigl"."
  808.  
  809.  
  810. checkconfig:
  811.  
  812.    status 26
  813.    okaystring=result
  814.    status 27
  815.    cancelstring=result
  816.  
  817.    query dirflags
  818.    olddirflags=result
  819.    if olddirflags<0 then  /* bug in DOpus? */
  820.       olddirflags=256+olddirflags
  821.    if bittst(d2c(olddirflags),5) then do
  822.       request "The config setting 'Re-read changed buffers'"lf"must be switched off. Shall I do this for you?"
  823.       if ~result then do
  824.      remember  /* something to restore */
  825.      call quitit "Error, config setting 'Re-read changed buffers' must be switched off."
  826.      end
  827.       modify dirflags olddirflags-32
  828.       end
  829.  
  830.    remember                /* remember user settings */
  831.    busy on
  832.    query updateflags
  833.    follow=bittst(d2c(result),1)        /* scroll window to follow operations? */
  834.    modify updateflags 0            /* no progress indicator */
  835.    query deleteflags
  836.    askdelete=bittst(d2c(result),0)    /* ask before deleting? */
  837.    modify deleteflags 8            /* don't ask when deleting internal */
  838.    modify replaceflags 1        /* don't ask when replacing internal */
  839.    modify iconflags 0            /* no icons please */
  840.    query font 2                /* text viewer font */
  841.    parse var result fontname '.font/' fontsize
  842.    return
  843.  
  844.  
  845. quitit:
  846.  
  847.    parse arg topline
  848.    status 26 set okaystring        /* restore okay and */
  849.    status 27 set cancelstring        /* cancel strings */
  850.    restore                   /* restore user settings */
  851.    if topline~=="" then
  852.       toptext topline            /* display final message */
  853.    if pos("Error",topline)>0 then
  854.       beep                /* an error occurred */
  855.    busy off                /* busy mouse pointer off */
  856.    exit                    /* stop script here */
  857.